<?php
//    require_once($_SERVER['DOCUMENT_ROOT'] . '/auth/auth.php');
	require_once('auth/auth.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

	<title>Experiment launcher</title>

	<?php
		include('head.php');
	?>

</head>


<body>
	<?php 
		$header_title = 'Welcome ' . $_SESSION['SESS_USER_FNAME'] . ' ' . $_SESSION['SESS_USER_LNAME'] . '!';
		include('header.php'); 
		include('menubar.php');
	?>

	<?php
		$command = '/opt/experiment/script/expmanager-client-refresh.sh';
		passthru($command);
	?>

	<form class="summary">

	<?php

	$userid = $_SESSION['SESS_USER_ID'];
	//Include database connection details
    require_once('db/config-exp.php');

			//Connect to mysql server
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
    if($link) { 
      $db = mysql_select_db(DB_DATABASE);
      if($db) {
        $qry="Select experiment_web.id, experiment_web.name, experiment_web.time, EXPERIMENTS.RESULTATS from experiment_web inner join EXPERIMENTS ON experiment_web.id=EXPERIMENTS.IDEXPERIMENT WHERE experiment_web.user_id=EXPERIMENTS.USUARI;"; 
       $result=mysql_query($qry);

        if($result) {
		  if(mysql_num_rows($result) >= 1) {
        	
		echo "<label>";
		  while($row=mysql_fetch_array($result)){
			echo "<li>" . $row['id'] . " " .$row['name'] . " <a href=\" view.php?id=" .$row['id'] . "\"> ".$row['RESULTATS'] . "</a> ".$row['time'] . "</ul>";
		  }
		echo "</label>";
	} else {
           echo "<label>No tienes ningun experimento.</label>";

        }
        }
      }
    }
	?>

	</form>
	
</body>

</html>
